#!/bin/sh

APP_HOME=`cd $(dirname $0);pwd`
PATH=/kingdee/jdk8/bin:$PATH:$HOME/bin:/sbin:/usr/bin:/usr/sbin:$APP_HOME/lib
JAVA_COM=`which java`

CONF_DIR=$APP_HOME/config:$APP_HOME/resources
JAVA_OPTS="-Xms512m -Xmx1024m  -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError"
LIB_DIR=$APP_HOME
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'`


echo "Java Version:"$JAVA_COM
echo "lib_dir"$LIB_DIR
echo "lib_jars"$LIB_JARS

cd $APP_HOME

pid=`ps -ef | grep $LIB_JARS | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
   kill -9 $pid
fi


echo "Current Dir: "`pwd`
nohup $JAVA_COM  $JAVA_OPTS  -Djava.awt.headless=true -Dfile.encoding=utf-8 -jar $LIB_JARS   & echo $!> $APP_HOME/run.pid
echo $JAVA_COM   $JAVA_OPTS " -Djava.awt.headless=true -Dfile.encoding=utf-8 -jar" $LIB_JARS" &"
sleep 5
echo "Done.."
exit 0;
